﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;

using Fuse8.DomainFramework.Common;

using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.BizFacade.Services;

namespace Fuse8.ContentManagementFramework.Web.MvcPowered
{
    public static class CmsMediaGalleryHtmlHelperExtension
    {
        public static CmsMediaGallery MediaGallery(this HtmlHelper htmlHelper, int mediaId, object htmlAttributes = null)
        {
            return new CmsMediaGallery(htmlHelper, mediaId).Attributes(htmlAttributes);
        }
    }
    
    public class CmsMediaGallery : CmsMvcBaseComponent<CmsMediaGallery, IEnumerable<CmsMediaContent>>
    {
        #region Constructors

        public CmsMediaGallery(HtmlHelper htmlHelper, int mediaId)
            : this(htmlHelper, new CmsMediaService().FindOne(mediaId))
        { }

        public CmsMediaGallery(HtmlHelper htmlHelper, CmsMedia media)
            : base(htmlHelper)
        {
            Guard.ArgumentNotNull(media, "media");

            Value = media.MediaContents;

            Component = this;
        }

        #endregion
    }
}
